﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Expand.Collections.Generic;

namespace Expand.Patterns.Command
{
    internal class CompoundCommand : ICommand
    {
        private LinkedList<ICommand> _CommandCollection;

        public CompoundCommand(LinkedList<ICommand> commandCollection)
        {
            _CommandCollection = commandCollection;
        }

        public object Receiver
        {
            get { return null; }
        }

        public void Execute()
        {
            foreach (ICommand command in _CommandCollection.Reverse())
                command.Execute();
        }

        public void UnExecute()
        {
            foreach (ICommand command in _CommandCollection)
                command.UnExecute();
        }
    }
}
